<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        class Logger {
            constructor() {
                // console.log(11, this);
                // 修改函数的this指向
                this.printName = this.printName.bind(this)
            }
            print() {
                // console.log(this);
                // 调用另一个方法
                this.printName('Tom')
            }
            printName(name='Tony') {
                console.log(name);
            }
        }

        let logger1 = new Logger(); // 这是一个实例对象 万物皆对象
        // logger1.print()
        // logger1.printName('Tom')
        let {
            print,
            printName
        } = logger1; // 将logger1的print方法提取出来单独使用，此时this指向是undefined
        printName('Mabaoguo');
    </script>
</body>
</html>